using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Champ
{
    //Stores data for rendering and draws the texture to the screen
    public class Sprite
    {
        public Texture2D[] texture = new Texture2D[20];
        public Vector2 position = Vector2.Zero;
        public Rectangle? sourceRect = null;
        public Color color = Color.White;
        public float rotation = 0f;
        public Vector2 origin = Vector2.Zero;
        public float scale = 1f;
        public SpriteEffects effects = SpriteEffects.None;
        public float layerDepth = 0;
        public int whichtexture = 0; 
       
        //Draws the texture 
        public void Draw(SpriteBatch spriteBatch)
        {
            if (texture == null)
            {
                return;
            }
            spriteBatch.Draw(texture[whichtexture], position, sourceRect, color, rotation, origin, scale, effects, layerDepth);
        }
        
        //If a sprite is made of multiple layers the layers[] will draw starting w/ the first layer listed in the array
        public void DrawLayers(SpriteBatch spriteBatch, int[] layers)
        {
            for (int i = 0; i < layers.Length; i++)
            {
                spriteBatch.Draw(texture[layers[i]], position, sourceRect, color, rotation, origin, scale, effects, layerDepth);
            }
        }
        
        //Takes in an angle (in degrees) and a position relative to the display vector and rotates it.
        public void Rotate(double angle, Vector2 rotationAxis)
        {
            origin = rotationAxis;
            rotation +=(float)(angle * (Math.PI/180));
        }
    }
}